package Demo;

import java.util.HashSet;
import java.util.Iterator;

/**
 * @author げっしょく
 * @date 2021/7/27
 */
public class Hash {
    public static void main(String[] args) {
        HashSet<Per> hs = new HashSet<>();
        Per p1 = new Per("xiaohei", 20);
        Per p2 = new Per("xiaohei", 20);
        Per p3 = new Per("lisi", 25);
        Per p4 = new Per("zhangsan", 27);
        hs.add(p1);
        hs.add(p2);
        hs.add(p3);
        hs.add(p4);
        System.out.println(p4);
        Iterator<Per> iterator = hs.iterator();
        while (iterator.hasNext()) {
            Per next = iterator.next();
            System.out.println(next);
        }
        for (Per h : hs) {
            System.out.println(h);
        }
    }
}
